package com.xbao.dao;

import com.xbao.model.Stu;
import com.xbao.model.StuExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface StuMapper {
    @SelectProvider(type=StuSqlProvider.class, method="countByExample")
    int countByExample(StuExample example);

    @DeleteProvider(type=StuSqlProvider.class, method="deleteByExample")
    int deleteByExample(StuExample example);

    @Delete({
        "delete from stu",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into stu (name, birthday, ",
        "tel, mobile, comments, ",
        "type, headurl, stuno, ",
        "sex, address, weixin, ",
        "orgid, createtime, ",
        "updatetime, status, ",
        "flag)",
        "values (#{name,jdbcType=VARCHAR}, #{birthday,jdbcType=BIGINT}, ",
        "#{tel,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{comments,jdbcType=VARCHAR}, ",
        "#{type,jdbcType=INTEGER}, #{headurl,jdbcType=VARCHAR}, #{stuno,jdbcType=INTEGER}, ",
        "#{sex,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{weixin,jdbcType=VARCHAR}, ",
        "#{orgid,jdbcType=BIGINT}, #{createtime,jdbcType=BIGINT}, ",
        "#{updatetime,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, ",
        "#{flag,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(Stu record);

    @InsertProvider(type=StuSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(Stu record);

    @SelectProvider(type=StuSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.BIGINT),
        @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="headurl", property="headurl", jdbcType=JdbcType.VARCHAR),
        @Result(column="stuno", property="stuno", jdbcType=JdbcType.INTEGER),
        @Result(column="sex", property="sex", jdbcType=JdbcType.INTEGER),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="weixin", property="weixin", jdbcType=JdbcType.VARCHAR),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="flag", property="flag", jdbcType=JdbcType.INTEGER)
    })
    List<Stu> selectByExample(StuExample example);

    @Select({
        "select",
        "id, name, birthday, tel, mobile, comments, type, headurl, stuno, sex, address, ",
        "weixin, orgid, createtime, updatetime, status, flag",
        "from stu",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.BIGINT),
        @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="comments", property="comments", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="headurl", property="headurl", jdbcType=JdbcType.VARCHAR),
        @Result(column="stuno", property="stuno", jdbcType=JdbcType.INTEGER),
        @Result(column="sex", property="sex", jdbcType=JdbcType.INTEGER),
        @Result(column="address", property="address", jdbcType=JdbcType.VARCHAR),
        @Result(column="weixin", property="weixin", jdbcType=JdbcType.VARCHAR),
        @Result(column="orgid", property="orgid", jdbcType=JdbcType.BIGINT),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.BIGINT),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.BIGINT),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="flag", property="flag", jdbcType=JdbcType.INTEGER)
    })
    Stu selectByPrimaryKey(Long id);

    @UpdateProvider(type=StuSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Stu record, @Param("example") StuExample example);

    @UpdateProvider(type=StuSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Stu record, @Param("example") StuExample example);

    @UpdateProvider(type=StuSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Stu record);

    @Update({
        "update stu",
        "set name = #{name,jdbcType=VARCHAR},",
          "birthday = #{birthday,jdbcType=BIGINT},",
          "tel = #{tel,jdbcType=VARCHAR},",
          "mobile = #{mobile,jdbcType=VARCHAR},",
          "comments = #{comments,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=INTEGER},",
          "headurl = #{headurl,jdbcType=VARCHAR},",
          "stuno = #{stuno,jdbcType=INTEGER},",
          "sex = #{sex,jdbcType=INTEGER},",
          "address = #{address,jdbcType=VARCHAR},",
          "weixin = #{weixin,jdbcType=VARCHAR},",
          "orgid = #{orgid,jdbcType=BIGINT},",
          "createtime = #{createtime,jdbcType=BIGINT},",
          "updatetime = #{updatetime,jdbcType=BIGINT},",
          "status = #{status,jdbcType=INTEGER},",
          "flag = #{flag,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Stu record);
}